package ui.adapter;

import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fy.fyzf.R;
import com.fy.fyzf.bean.CheckWorkListBean;
import com.fy.fyzf.utils.DateUtils;
import com.fy.fyzf.utils.SPUtils;

import java.util.List;

public class CheckWorkRecordAdapter extends BaseQuickAdapter<CheckWorkListBean.ListBean, BaseViewHolder> {

    public CheckWorkRecordAdapter() {
        super(R.layout.item_checkwork_record_new);
    }

    @Override
    protected void convert(BaseViewHolder helper, CheckWorkListBean.ListBean item) {
        helper.setText(R.id.tv_date, DateUtils.formatDate(item.getDayTime()) +"("+item.getDayCheckDetailsVos().get(0).getWeek()+")");
        String name = SPUtils.getInstance(mContext).getString("name", "");
        helper.setText(R.id.tv_name,name);
        LinearLayout llWork = helper.getView(R.id.ll_work);
        LinearLayout llOut = helper.getView(R.id.ll_out);
        LinearLayout llOff = helper.getView(R.id.ll_off);
        List<CheckWorkListBean.ListBean.DayCheckDetailsVosBean> dayCheckDetailsVos = item.getDayCheckDetailsVos();
        //3：外出 4:上班 5:下班
        for (int i = 0; i < dayCheckDetailsVos.size(); i++) {
            if (dayCheckDetailsVos.get(i).getWorkType() == 3) {
                llOut.setVisibility(View.VISIBLE);
                helper.setText(R.id.tv_out_work, "外出时间 " + dayCheckDetailsVos.get(i).getCreateTime());
            } else if (dayCheckDetailsVos.get(i).getWorkType() == 4) {
                llWork.setVisibility(View.VISIBLE);
                helper.setText(R.id.tv_to_work, "上班时间 " + dayCheckDetailsVos.get(i).getEndTime());
            } else if (dayCheckDetailsVos.get(i).getWorkType() == 5) {
                llOff.setVisibility(View.VISIBLE);
                helper.setText(R.id.tv_off_work, "下班时间 " + dayCheckDetailsVos.get(i).getEndTime());
            }
        }
       /* helper.setText(R.id.tv_company, item.getCompanyName())
                .setText(R.id.tv_name, item.getUserName())
                .setText(R.id.tv_time, "打卡时间: "+item.getCreateTime())
                .setText(R.id.tv_week, item.getWeek());
        switch (item.getWorkType()) {
            case 1:
                helper.setText(R.id.tv_type, "勘察");
                break;
            case 2:
                helper.setText(R.id.tv_type, "看房");
                break;
            case 3:
                helper.setText(R.id.tv_type, "外出");
                break;
            case 4:
                helper.setText(R.id.tv_type, "上班");
                break;
            case 5:
                helper.setText(R.id.tv_type, "下班");
                break;

        }*/
    }
}
